<?
class infoModel extends iMVC_Model{

   public $_table='info'; 
   public $_pk='info_id';
   public $a=1;

   public function fetchByKeyWord($keyword,$city=null,$class=null){
   

       $reader=$this->db->getDbReader();
       $sql="select * from $this->_table where concat(info_name,info_addres) like '%$keyword%'";
       if($city!=null){
           $sql.=" and info_city like '%$city%'"; 
       }
       if($class!=null){
           $sql.=" and info_class like '%$class%'"; 
       }
       echo $sql;
       $res=$reader->readByQuery($sql);
       if($res!=null){
            return $res;
        }
        else{
            return false; 
        }  
   
   
   }





   
   public function fetchPhotos(){
   
        $photo=new photoModel();
        $reader=$this->db->getDbReader();
        $sql="select * from $photo->_table where info_id=$this->info_id";
        $res=$reader->readByQuery($sql);
        if($res!=null){
            return $res;
        }
        else{
            return false; 
        }
   
   
   }
   
   public function fetchComment($page,$size){

        $cm=new commentModel();
        $reader=$this->db->getDbReader();
        $start=($page-1)*$size;
        $sql="select * from $cm->_table where info_id=$this->info_id order by comment_time desc limit $start,$size ";
        $res=$reader->readByQuery($sql);
        if($res!=null){
            return $res;
        }
        else{
            return false; 
        }
   
   
   
   
   }
   public function fetchAllComment(){

        $cm=new commentModel();
        $reader=$this->db->getDbReader();
        $sql="select * from $cm->_table where info_id=$this->info_id order by comment_time desc";
        $res=$reader->readByQuery($sql);
        if($res!=null){
            return $res;
        }
        else{
            return false; 
        }
   
   
   
   
   }






  
}


// vim600:ts=4 st=4 foldmethod=marker foldmarker=<<<,>>>
// vim600:syn=php commentstring=//%s
